const fs = require('fs');

/**
 * 异步读取文件内容, 返回Promise<>
 * @param {string} filename 文件名
 */
const asyncRead = filename => {
  return new Promise((resolve, reject) => {
    console.log('do aysnc read');
    fs.readFile(filename, (err, data) => {
      if (err) {
        reject(err);
      } else {
        const a = resolve(data.toString());
        return a;
      }
    });
  });
};

module.exports = asyncRead;
